package com.siblings.loan.ui.loan.impl

import com.siblings.loan.http.ApiService
import com.siblings.loan.http.ApiService.addCommonParams
import com.siblings.loan.http.HttpHelper
import com.siblings.loan.http.IHttpCallback
import org.json.JSONObject

/**
 * Siblings
 * @Author wwdeng
 * @CreateTime: 2024/6/17 13:45
 * @Annotation：审核中、拒绝、放贷中、放贷中法语 Model 实现
 */
class SibLoanCommonModelImpl {

    /**
     * 获取贷款信息
     */
    fun loadSibLoanInfoAction(callBack: IHttpCallback){
        val httpUrl = ApiService.getHttpUrl(ApiService.API_URL.SIB_API_LOAN_INFO_URL)
        val params = JSONObject().addCommonParams().apply {
            put("path", ApiService.API_PATH.SIB_API_LOAN_APPLY_PATH)
        }
        HttpHelper.postSibAction(httpUrl,params,callBack)
    }

    /**
     * 获取绑定的账户列表
     */
    fun loadSibLoanAccountAction(callBack: IHttpCallback){
        val httpUrl = ApiService.getHttpUrl(ApiService.API_URL.SIB_API_LOAN_INFO_URL)
        val params = JSONObject().addCommonParams().apply {
            put("path", ApiService.API_PATH.SIB_API_ACCOUNT_LIST_PATH)
        }
        HttpHelper.postSibAction(httpUrl,params,callBack)
    }

    /**
     * 获取推荐APP列表
     */
    fun loadSibRecommendAppAction(callBack: IHttpCallback){
        val httpUrl = ApiService.getHttpUrl(ApiService.API_URL.SIB_API_LOAN_INFO_URL)
        val params = JSONObject().addCommonParams().apply {
            put("path", ApiService.API_PATH.SIB_API_RECOMMEND_APP_LIST_PATH)
        }
        HttpHelper.postSibAction(httpUrl,params,callBack)
    }

    /**
     * 评分配置
     */
    fun loadSibScoreCommentAction(callBack: IHttpCallback) {
        val httpUrl = ApiService.getHttpUrl(ApiService.API_URL.SIB_API_LOAN_INFO_URL)
        val params = JSONObject().addCommonParams().apply {
            put("path", ApiService.API_PATH.SIB_API_STAR_COMMENT_PATH)
        }
        HttpHelper.postSibAction(httpUrl,params,callBack)
    }

    /**
     * 提交绑卡
     */
    fun submitSibBindAccountAction(mobile: String, walletChannel: String, bindFlag:String, callBack: IHttpCallback){
        val httpUrl = ApiService.getHttpUrl(ApiService.API_URL.SIB_API_LOAN_INFO_URL)
        val params = JSONObject().addCommonParams().apply {
            put("path", ApiService.API_PATH.SIB_API_ACCOUNT_ADD_PATH)
            put("walletMobile", mobile)
            put("walletMobileConfirm", mobile)
            put("walletChannel", walletChannel)
            put("addBindFlag", bindFlag)
        }
        HttpHelper.postSibAction(httpUrl, params, callBack)
    }

    /**
     * 删除账户
     */
    fun deleteSibAccountAction(ids: String, callBack: IHttpCallback) {
        val httpUrl = ApiService.getHttpUrl(ApiService.API_URL.SIB_API_LOAN_INFO_URL)
        val params = JSONObject().addCommonParams().apply {
            put("path", ApiService.API_PATH.SIB_API_ACCOUNT_DELETE_PATH)
            put("ids", ids)
        }
        HttpHelper.postSibAction(httpUrl, params, callBack)
    }

}